#include "src/ltpanic.h"

#include <stdio.h>
#include <stdlib.h>

static void
DefaultPanicHook(char const* message) {
    fprintf(stderr, "lt_PANIC: %s\n", message);
    fflush(stderr);
}

lt_PanicHook g_PanicHook = DefaultPanicHook;

void
lt_Panic(char const* message) {
    if (g_PanicHook != NULL) {
        g_PanicHook(message);
    }

    abort();
}

void
lt_SetPanicHook(lt_PanicHook hook) {
    g_PanicHook = hook;
}
